How to Create a Thread
There are different ways of creating threads using OCL, and the method chosen
will often depend on what you want the thread to do.
Example of creating a thread to call an object method:
MyDlgClass *frame = new MyDlgClass();
IThreadMemberFn *myThreadMemberFn = new IThreadMemberFn(frame, MyDlgClass::doSomething) );
IThread *myThread = new IThread( myThreadMemberFn );
Example of creating a thread to call an entire class:
class MyThreadClass : public IThreadFn
...
int main()
{
...
MyThreadClass *myThreadFn = new MyThreadClass();
IThread *myThread = new IThread( myThreadFn );
- Warning:
- When using IThreadFn as opposed to IThreadMemberFn, the class being
created must inherit from IThreadFn, and must contain the method
run()
- Note:
- See also
Index of Samples on Hobbes
Page generated by Stéphane Charette on 1997 June 30
Open Class Library (OCL) FAQ © Stéphane Charette, 1997